
from time import sleep
from selenium.webdriver.common.by import By

from seleniumtest_base.base.base_page import BasePage


class AddWorkExperisence(BasePage):
    #页面元素
    time_from_loc = (By.ID,"work_timefrom_input")
    timeyear_from_loc = (By.XPATH,"//div[@id='work_timefrom_div']//span[@year='2020']")
    timemonth_from_loc = (By.XPATH,"//div[@id='work_timefrom_div']//span[@month='1']")

    time_to_loc = (By.ID,"work_timeto_input")
    timeyear_to_loc = (By.XPATH, "//div[@id='work_timeto_div']//span[@year='2021']")
    timemonth_to_loc = (By.XPATH, "//div[@id='work_timeto_div']//span[@month='1']")
    company_name_loc = (By.ID,"work_compname")
    company_name1_loc = (By.XPATH,"//span[@data-value='大连华信计算机技术股份有限公司']")

    function_loc = (By.ID,"work_func_click")
    function_name_loc = (By.XPATH,"//em[text()='后端开发']")
    function_name1_loc = (By.XPATH, "//em[text()='Python开发工程师']")
    industry_loc = (By.ID, "work_industry_click")
    industry_name_loc = (By.ID, "work_industry_click_center_right_list_category_01_01")
    department_loc = (By.ID, "work_department")
    companysize_list_loc = (By.ID, "work_companysize_list")
    companysize_list1_loc = (By.XPATH, "//span[text()='少于50人']")
    companytype_list_loc = (By.ID, "work_companytype_list")
    companytype_list1_loc = (By.XPATH, "//span[text()='外资（欧美）']")
    workdescribe_loc = (By.ID, "work_describe")
    worktype_list_loc = (By.ID, "work_type_list")
    worktype1_list_loc = (By.XPATH, "//span[text()='全职']")
    work_save_loc = (By.ID, "work_save_")
    work_cancel_loc = (By.ID, "work_cancel_")
    work_del_name = (By.XPATH, "//span[@title='软件工程师']")
    work_del = (By.XPATH,"//em[@id='work_delete_244626243']")
    my_add_job = (By.ID, "work_new")
    del_cancel = (By.XPATH,"//span[text()='取消']")
    del_ok = (By.XPATH,"//span[text()='确定']")



    #页面动作

    @classmethod
    def add_work(self,companyname,department,workdescribe):
        BasePage.click(AddWorkExperisence.my_add_job)
        sleep(1)
        BasePage.click(AddWorkExperisence.time_from_loc)
        sleep(1)
        BasePage.click(AddWorkExperisence.timeyear_from_loc)
        sleep(1)
        BasePage.click(AddWorkExperisence.timemonth_from_loc)
        sleep(1)
        BasePage.click(AddWorkExperisence.time_to_loc)
        sleep(1)
        BasePage.click(AddWorkExperisence.timeyear_to_loc)
        sleep(1)
        BasePage.click(AddWorkExperisence.timemonth_to_loc)
        sleep(2)
        BasePage.send_keys(AddWorkExperisence.company_name_loc,companyname)
        sleep(2)
        BasePage.click(AddWorkExperisence.company_name1_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.function_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.function_name_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.function_name1_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.industry_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.industry_name_loc)
        sleep(2)
        BasePage.send_keys(AddWorkExperisence.department_loc,department)
        sleep(2)
        BasePage.click(AddWorkExperisence.companysize_list_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.companysize_list1_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.companytype_list_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.companytype_list1_loc)
        sleep(2)
        BasePage.send_keys(AddWorkExperisence.workdescribe_loc,workdescribe)
        sleep(2)
        BasePage.click(AddWorkExperisence.worktype_list_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.worktype1_list_loc)
        sleep(2)
        BasePage.click(AddWorkExperisence.work_save_loc)


    @classmethod
    def del_work(cls):
        BasePage.click(AddWorkExperisence.work_del_name)
        sleep(2)
        BasePage.click(AddWorkExperisence.work_del)
        sleep(2)
        BasePage.click(AddWorkExperisence.del_cancel)






